
// Qt
#include <QtCore>
#include <QtGui>

// GMQtExt
#include <messageboxes/messageboxes.h>

// local
#include "myglwidget.h"

// header
#include "mainwindow.h"

#include <gmPButterfly.h>
#include <gmPRoseCurve.h>
#include <gmPERBSCurve.h>
#include <gmPCircle.h>





MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {

  _widget = new MyGLWidget(this);
  setCentralWidget( _widget );

  _scene = _widget;

  QMenu *file_menu = menuBar()->addMenu( tr("&File") );
  QMenu *file_help = menuBar()->addMenu( tr("&Help") );

  QAction *action_openfile = new QAction( tr("&open"), this );
  file_menu->addAction(action_openfile);

  QAction *action_quit = new QAction( tr("&Quit"), this );
  file_menu->addAction(action_quit);

  QAction *action_about_gmlib = new QAction( tr("About &GMlib"), this );
  file_help->addAction(action_about_gmlib);

  connect( action_openfile, SIGNAL(triggered()), this, SLOT(_slotOpenFile()) );
  connect( action_quit, SIGNAL(triggered()), this, SLOT(_slotQuit()) );
  connect( action_about_gmlib, SIGNAL(triggered()), this, SLOT(_slotAboutGMlib()) );

}

MainWindow::~MainWindow() {}

void MainWindow::_slotOpenFile() {
  QString fileName = QFileDialog::getOpenFileName(this, tr("Open Image"));
	

}

void MainWindow::_slotAboutGMlib() {

  GMQtExt::MessageBoxes::aboutGMlib( centralWidget() );
}

void MainWindow::_slotQuit() {

  // Ask for confirmation on clear
  QMessageBox::StandardButton choice = QMessageBox::question( this, tr("Quit?"), tr("Sure you want to quit?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes );
  switch( choice ) {

    case QMessageBox::No:
      return;
      break;

    case QMessageBox::Yes:
    default:

      // Remove all Selections
      close();
      break;
  }
}

void MainWindow::initScene() {
  _widget->initScene();

	
	GMlib::PCurve<float> *myCurve = new GMlib::PRoseCurve<float>();
	_widget->insert( myCurve );
	myCurve->replot(5000);

	//GMlib::PCurve<float> *myCurve = new GMlib::PCircle<float>(1.0f);
	//_widget->insert( myCurve );
	//myCurve->replot(60);

	GMlib::PERBSCurve<float> *erbsCurve = new GMlib::PERBSCurve<float>( myCurve, 56,2 );
  _widget->insert(erbsCurve);
  erbsCurve->replot(300);
  erbsCurve->setColor( GMlib::GMcolor::Green );
  erbsCurve->showLocalPatches();
	erbsCurve->setCollapsed(false);

 // Data punkter
  //  int punkter = 2;

  //  GMlib::DVector< GMlib::DVector< GMlib::Vector<float,3> > > dp;
  //  dp.setDim(punkter);
  //  for(int i = 0; i < punkter; i++)
  //  {
  //      dp[i].setDim(2);
  //  }

  //  for(int i=0; i<punkter; i++)
  //  {
  //      float x = float(i) * 2*M_PI / punkter;
  //      dp[i][0]= GMlib::Vector3D<float>(2*x,2*sin(x),2*cos(x)); // Punkt
		//		dp[i][0]= GMlib::Vector3D<float>(2,2*cos(x),2*-sin(x)); // Punkt
		//}

		//// PERBSCurve( const DVector< DVector< Vector<T,3> > >& c, T s = T(0), T e = T(1), bool closed = false );
  //  GMlib::PERBSCurve<float> *erbsCurve = new GMlib::PERBSCurve<float>(dp, 0.0, 2.0*M_PI, false);
  //  _widget->insert(erbsCurve);
  //  erbsCurve->replot();
    //erbsCurve->setColor( GMlib::GMcolor::Green );
    //erbsCurve->showLocalPatches();





}

























